import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-10-21
 * Time: 21:39
 */
@WebServlet("/sendCookie")
public class sendCookie extends HttpServlet {
    @Override
    //把一个自定义的cookie数据返回到浏览器这里
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Cookie cookie=new Cookie("date","2023-10-21");
        resp.addCookie(cookie);
        Cookie cookie1=new Cookie("time","21:44");
        resp.addCookie(cookie1);
        resp.getWriter().write("okkk");
    }
}
